﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BestLifePOS_Core.Data.Core;
using BestLifePOS_Core.DomainObjects;
using System.Data.SqlClient;
using System.Data;
using BestLifePOS_Core.Exceptions.DataBase;

namespace BestLifePOS_Core.Data.Commands
{
    class BestLifePRinDetailsByPridDataAction : BestLifeDataAction<DataTable>
    {
        private string GvPRid;
        private string GvStatus;
        DataTable GvTable = new DataTable();
        public BestLifePRinDetailsByPridDataAction(string PPRid, string PStatus)
        {
            GvPRid = PPRid;
            GvStatus = PStatus;
        }

        public override DataTable Body(SqlConnection PConn)
        {
            try
            {

                #region Datatable

                GvTable.Columns.Add("Pr_ID");
                GvTable.Columns.Add("Qty");
                GvTable.Columns.Add("PL_ID");
                GvTable.Columns.Add("Status");
                GvTable.Columns.Add("Last_Modify");
                GvTable.Columns.Add("User_Modify");
                GvTable.Columns.Add("Description");
                GvTable.Columns.Add("Pro_ID");
                GvTable.Columns.Add("Brand");
                GvTable.Columns.Add("Pro_Name");
                GvTable.Columns.Add("Pur_Price");
                GvTable.Columns.Add("PV");
                GvTable.Columns.Add("BV");
                GvTable.Columns.Add("Ret_Price");
                #endregion


                DataTable LvList = new DataTable();

                SqlCommand LvCommand = new SqlCommand();
                LvCommand.Connection = PConn;
                LvCommand.CommandType = CommandType.StoredProcedure;
                LvCommand.CommandText = "dbo.GetPRinDetailsByPRID";
                LvCommand.Parameters.Add(new SqlParameter("@PR_ID", GvPRid));
                LvCommand.Parameters.Add(new SqlParameter("@Status", GvStatus));
                SqlDataReader LvReader = LvCommand.ExecuteReader();
                while (LvReader.Read())
                {


                    GvTable.Rows.Add(GvTable.NewRow());

                    GvTable.Rows[GvTable.Rows.Count - 1][0] = LvReader.GetValue(0).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][1] = LvReader.GetValue(1).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][2] = LvReader.GetValue(2).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][3] = LvReader.GetValue(3).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][4] = LvReader.GetValue(4).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][5] = LvReader.GetValue(5).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][6] = LvReader.GetValue(6).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][7] = LvReader.GetValue(7).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][8] = LvReader.GetValue(8).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][9] = LvReader.GetValue(9).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][10] = LvReader.GetValue(10).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][11] = LvReader.GetValue(11).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][12] = LvReader.GetValue(12).ToString();
                    GvTable.Rows[GvTable.Rows.Count - 1][13] = LvReader.GetValue(12).ToString();




                }
                return GvTable;
            }
            catch (Exception)
            {
                return null;
            }
        }
       
    }
}
